//
//  DFStatuesViewModel.swift
//  新浪微博
//
//  Created by dafei on 16/5/27.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class DFStatuesViewModel: NSObject {
    
    var statues : DFStatus?
    //认证类型的图片
    var veritiedImage: UIImage?
    var mbrankImage: UIImage?
    var headImageURL: NSURL?
    
    
    
    
    //视图初始化
    init(statues: DFStatus) {
        super.init()
        self.statues = statues
        
        //处理用户头像
        headImageURL = NSURL(string: statues.user?.profile_image_url ?? "")
        //认证图片
        dealVeitiedImage()
        //用户等级
        dealMbrankImage()
        
    }
    
    
}
extension DFStatuesViewModel {
    
    private func dealMbrankImage() {
        
            //用户等级
            if statues?.user?.mbrank > 0 && statues?.user?.mbrank < 7 {
                
                //转译会自动加上 optional
                let image = UIImage(named: "common_icon_membership_level\(statues?.user?.mbrank ?? 0)")
                mbrankImage = image
                
            }
    
        }
    
    private func dealVeitiedImage() {
        let veriteidType = statues?.user?.verified ?? 0
        if veriteidType == 1 {
        
        veritiedImage = UIImage(named: "avatar_vip")
        
        }
    
    }
    
    
    
    
    }
    

